<template>
  <div class="tmpl" >
    <nav-bar title="新闻详情"/>
    <div v-for="(item ,index) in newsdetails" :key="item.id" class="news-detail">
      <div class="news-title" >
        <p>{{item.title}}</p>
        <div>
          <span>{{item.click}}次点击</span>
          <span>分类:民生经济</span>
          <span>添加时间:{{item.add_time | formatDate}}</span>
        </div>
      </div>
      <div class="news-content" v-html="item.content"></div>
    </div>
  </div>
</template>
<script>
  export default {
  	data(){
  		return{
  			newsdetails:[]
      }
    },
  	created(){
  		let obj = this;
  		//获取当前路由的参数的两种方法：
      //1.this.$route.query.id
      //2.this.$router.currentRoute.query.id
//  		console.log(this.$route)
  		let newID = this.$router.currentRoute.query.id
		  this.$axios.get('getNew/'+newID)
			  .then(res =>{
				  this.newsdetails = res.data.message;
			  })
			  .catch(err =>console.log('获取新闻详情失败',err))
    }
  }
</script>
<style scoped>
  .news-title p {
    color: #0a87f8;
    font-size: 20px;
    font-weight: bold;
  }

  .news-title span {
    margin-right: 30px;
  }

  .news-title {
    margin-top: 5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  }


  /*主体文章的左右距离*/

  .news-content {
    padding: 10px 10px;
  }
  .news-detail{
    margin-bottom: 40px;
  }
</style>
